#include "Prop.h"
#include <stdlib.h>

prop *CreateProp(enum PropType type, void *ptr)
{
    prop *p = (prop *)malloc(sizeof(prop));
    if(p == NULL)
        return NULL;
    p->type = type;
    p->ptr = ptr;
    return p;
}

void FreeProp(void *p, void (*clearPtr)(void *))
{
    prop *pro = (prop*)p;
    clearPtr(pro->ptr);
    free(pro);
}

weapon *CreateWeapon(const char *name, int attack,enum Effect effect)
{
    weapon *w = (weapon *)malloc(sizeof(weapon));
    if(w == NULL)
        return NULL;
    w->attack = attack;
    w->effect = effect;
    w->name =  GetString(name);
    return w;
}

void FreeWeapon(void *ptr)
{
    weapon * w = (weapon*)ptr;
    ClearString(&w->name);
    free(w);
}
